// hotel-management-frontend/src/App.js

import React from 'react';
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import { ConfigProvider } from 'antd'; // <-- 新增：导入 ConfigProvider
import zhCN from 'antd/locale/zh_CN'; // <-- 新增：导入中文语言包

import AppLayout from './components/Layout';

// Admin components
import RoomManagement from './admin/RoomManagement';
import GuestManagement from './admin/GuestManagement';
import CheckinManagement from './admin/CheckinManagement';
import Statistics from './admin/Statistics';
import Dashboard from './admin/Dashboard';
import BulkImport from './admin/BulkImport';
import MenuItemManagement from './admin/MenuItemManagement';
import CheckinDetails from './admin/CheckinDetails';

// Client components
import ClientHistory from './client/History';
import ClientProfile from './client/Profile';

// Admin Routes Wrapper
const AdminRoutes = () => (
    <AppLayout isAdmin={true}>
        <Routes>
            <Route path="dashboard" element={<Dashboard />} />
            <Route path="rooms" element={<RoomManagement />} />
            <Route path="guests" element={<GuestManagement />} />
            <Route path="checkins" element={<CheckinManagement />} />
            <Route path="checkins/:id" element={<CheckinDetails />} />
            <Route path="statistics" element={<Statistics />} />
            <Route path="bulk-import" element={<BulkImport />} />
            <Route path="menu-items" element={<MenuItemManagement />} />
            <Route path="*" element={<Navigate to="dashboard" replace />} />
        </Routes>
    </AppLayout>
);

function App() {
    return (
        // <-- 新增：使用 ConfigProvider 包裹整个 Router
        <ConfigProvider locale={zhCN}>
            <Router>
                <Routes>
                    {/* Admin section */}
                    <Route path="/admin/*" element={<AdminRoutes />} />

                    {/* Client section */}
                    <Route path="/" element={<AppLayout isAdmin={false}><ClientHistory /></AppLayout>} />
                    <Route path="/client/history" element={<AppLayout isAdmin={false}><ClientHistory /></AppLayout>} />
                    <Route path="/client/profile" element={<AppLayout isAdmin={false}><ClientProfile /></AppLayout>} />

                    {/* Fallback route */}
                    <Route path="*" element={<Navigate to="/" replace />} />
                </Routes>
            </Router>
        </ConfigProvider>
        // <-- 新增：ConfigProvider 结束标签
    );
}

export default App;
